package a;

import java.util.Date;
import java.util.HashMap;

public class ExchangeRateFetcher {
	private HashMap<String,Rate> table = new HashMap<String,Rate>();
	private Date date;

	protected void setRate(String curr,float rate,String perCurr) {
		table.put(curr.toUpperCase(), new Rate(rate,perCurr));
	}

	public Rate getRate(String curr) {
		Rate f = table.get(curr.toUpperCase());
		if(f!=null) {
			return f;
		} else {
			return new Rate(Float.NaN,"SDR");
		}
	}

	public String[] currencies() {
		String[] curr = new String[table.size()];
		return table.keySet().toArray(curr);
	}

	public ExchangeRateFetcher setDate(Date d) {
		this.date = d;
		return this;
	}

	public Date getDate() {
		return this.date;
	}

	public void fetch() {}


	public static class Rate {
		public String perCurrency;
		public float value;
		public Rate(float value,String curr) {
			this.value = value;
			this.perCurrency = curr;
		}
	}
}
